//
//  LeftPicRightTextView.m
//  PPStar
//
//  Created by wind on 15/11/16.
//  Copyright © 2015年 wind. All rights reserved.
//

#import "LeftPicRightTextView.h"
#import "Masonry.h"
@implementation LeftPicRightTextView
-(id)initWithText:(NSString *)text imgName:(NSString *)imgName{
    self = [super initWithFrame:CGRectZero];
    if (self) {
        
        if (_leftImgView == nil) {
            _leftImgView = [[UIImageView alloc] init];
            _leftImgView.backgroundColor = [UIColor clearColor];
            _leftImgView.image = [UIImage imageNamed:imgName];
            [self addSubview:_leftImgView];
        }
        if (_text == nil) {
            _text = [[UILabel alloc] init];
            _text.backgroundColor = [UIColor clearColor];
            _text.font = [UIFont systemFontOfSize:15.f];
            _text.textColor = [UIColor whiteColor];
            _text.text = text;
            [self addSubview:_text];
        }
        
        UIImage *img = [UIImage imageNamed:imgName];
        [_leftImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(self);
            make.width.equalTo(@(img.size.width));
            make.right.equalTo(_text.mas_left);
        }];
        
        [_text mas_makeConstraints:^(MASConstraintMaker *make) {
            //                make.left.equalTo(_leftImgView.mas_right).offset(5);
            make.centerY.equalTo(_leftImgView);
            make.right.equalTo(self.mas_right);
            
        }];



    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
